#ifndef  SERIALLINK_H_INCLUDED
#define  SERIALLINK_H_INCLUDED

#if defined __cplusplus
extern "C" {
#endif

#include <stdbool.h>

#include "list.h"
#include "uart.h"

#define SL_MAX_MESSAGE_LENGTH   0xFF

typedef enum
{
    E_SL_OK,
    E_SL_ERROR,
    E_SL_NOMESSAGE,
    E_SL_ERROR_SERIAL,
    E_SL_ERROR_NOMEM,
} teSL_Status;

typedef struct SL_Message
{
    unsigned int u32Type;
    unsigned short u16Length;
    unsigned char *pu8Message;
    struct list_head list;
} SL_Message_ts;

typedef struct SL_FixMessage
{
    unsigned int u32Type;
    unsigned short u16Length;
    unsigned char pu8Message[SL_MAX_MESSAGE_LENGTH];
} SL_FixMessage_ts;

typedef struct SL_MessageCb
{
    unsigned int u32Type;

    void (*cb)( void * );

    struct list_head list;
} SL_MessageCb_ts;


teSL_Status eSL_Init( char *cpSerialDevice, unsigned int u32BaudRate );

teSL_Status eSL_Destroy( void );

teSL_Status eSL_SendMessage( unsigned int u32Type, unsigned short u16Length, void *pu8Message );

#if defined __cplusplus
}
#endif

#endif  /* SERIALLINK_H_INCLUDED */